package plugins

import (
	"github.com/quarkcloudio/quark-go/v2/pkg/builder"
	token "github.com/wsl/hi-go/plugins/token"
)

type VerificationTokenHandle struct{}

// 创建一个全局的处理函数包装器
func (p *VerificationTokenHandle) VerificationTokenHandler(next builder.Handle) builder.Handle {
	return func(c *builder.Context) error {
		//authToken
		authToken := c.EchoContext.Request().Header.Get("authToken")
		if authToken == "" {
			return c.JSONError("header 缺少token")
		}
		(&token.AdminClaims{}).ParseJWTToken(authToken)
		return next(c)
	}
}
